package com.example.myFirstWebmagic.airQualityForecasting;

import java.util.List;
import java.util.Map;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

/**
 * 
 * ClassName: AreaForecastPipeline 
 * @Description: TODO
 * @author xiongyao
 * @param <T>
 * @date 2017年3月13日
 */
public class AreaForecastPipeline implements Pipeline {
	
	private final AreaForecastDao repository;
	

	public AreaForecastPipeline(AreaForecastDao repository){
		this.repository=repository;
	}
	
	@Override
	public void process(ResultItems resultItems, Task task) {
		// TODO Auto-generated method stub
		for (Map.Entry<String, Object> entry : resultItems.getAll().entrySet()) {
            @SuppressWarnings("unchecked")
			List<EnAreaForecast> list= (List<EnAreaForecast>) entry.getValue();
            for(EnAreaForecast report:list){
            	repository.save(report);
            }
        }
	}

}
